<section>
    <div class="page_title">
        <h2 class="fl">发出的站内信</h2>
        <a class="fr top_rt_btn iconfont iconfont-fasong" href="{:U('admin/Msgtext/addMessage')}">发送站内信</a>
    </div>
    <ul class="admin_tab">
        <li><a class="active loadContent" href="{:U('admin/Msgtext/index')}">我发出的站内信</a></li>
        <li><a class="loadContent" href="{:U('admin/Msgtext/recmessage')}">收到的站内信</a></li>
    </ul>
    <!--发出的站内信-->
    {empty name="sendmsg"}
    <div class="admin_tab_cont" style="display: none;">
        <div class="not-data">你还没有发送过站内信哟！</div>
    </div>
    {else /}
        <table class="table">
            <tbody>
            <tr>
                <th>发送至</th>
                <th>内容详情</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            {volist name='sendmsg' id='v'}
                {if condition="$v['state'] == 1"}
                    <tr>
                        <td>{$v.msgto}</td>
                        <td style="width:40%;text-align: center">
                            <div style="text-align: center">{$v['msg']}</div>
                            <!--<textarea class="textarea" name="msg" readonly="readonly" style="width:500px;height:100px;">{$v['msg']}</textarea>-->
                        </td>
                        <td>{if condition=" $v['postdate']  neq 0 "}{$v.postdate|date='Y-m-d H:i', ###}{/if}</td>
                        <td>
                            <div class="action-buttons">
                                <a class="delsendMsg loadContent inner_btn" href="javascript:void(0)" data-id="{:encrypt_id($v.id)}">
                                    <!--<i class="iconfont iconfont-shanchu"></i>-->
                                    删除
                                </a>
                            </div>
                        </td>
                    </tr>
                {/if}
            {/volist}
            </tbody>
        </table>
        <aside class="paging">
            {$sendpage.html}
        </aside>
    {/empty}
</section>

<script type="text/javascript">
    $(".delMsg").click(function(){
        var id = $(this).data('id');
        msg({
            yes:'删除',
            no:'取消',
            txt:'确认删除?',
        },'question').then(function() {
            var send_data = {
                url:U('admin/Msgtext/delMsg'),
                type:'POST',
                data:{
                    id:id
                },
                dataType:'json',
            };
            send_ajax(send_data,function(response){
                if(response === false){
                    DEBUG && admin.log(ajax_error);
                    return false;
                }
                if(response.status == 1){
                    msg_success(response.data.info,'',1000);
                    setTimeout(function(){
                        admin.getContentByUrl(response.data.jumpurl);
                    },1000);
                }else{
                    msg_error(response.message);
                }
                admin.log(response);
            });
        }, function(miss) {
            //dismiss can be 'cancel', 'overlay', 'close', 'timer'
            //if (miss === 'cancel') {
            //msg('你取消了')
            //}
        });
    });


    $(".delsendMsg").click(function(){
        var id = $(this).data('id');
        msg({
            yes:'删除',
            no:'取消',
            txt:'确认删除?',
        },'question').then(function() {
            var send_data = {
                url:U('admin/Msgtext/delsendMsg'),
                type:'POST',
                data:{
                    id:id
                },
                dataType:'json',
            };
            send_ajax(send_data,function(response){
                if(response === false){
                    DEBUG && admin.log(ajax_error);
                    return false;
                }
                if(response.status == 1){
                    msg_success(response.data.info,'',1000);
                    setTimeout(function(){
                        admin.getContentByUrl(response.data.jumpurl);
                    },1000);
                }else{
                    msg_error(response.message);
                }
                admin.log(response);
            });
        }, function(miss) {
            //dismiss can be 'cancel', 'overlay', 'close', 'timer'
            //if (miss === 'cancel') {
            //msg('你取消了')
            //}
        });
    });
</script>